-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Created navigation bar #30
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far so good! Left a couple of comments and you need to add unit tests, msg on your thread if you need help or clarification.
@@ -0,0 +1,64 @@ | |||
import 'package:flutter/material.dart'; | |||
|
|||
class NavBar extends StatefulWidget { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add some documentation in the form of comments, check the other widgets for examples
flutter_app/lib/main.dart
Outdated
@@ -17,6 +18,9 @@ class App extends StatelessWidget { | |||
), | |||
routes: { | |||
'/': (BuildContext context) => HomePage(title: 'WARG IMACS'), | |||
'/logs': (BuildContext context) => const Placeholder(child: NavBar()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not exactly a requirement, but you can make the placeholders look a lot nicer
class PlaceholderScreen extends StatelessWidget {
const PlaceholderScreen({Key? key, required this.title}) : super(key: key);
final String title;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(title),
),
body: const Placeholder(),
bottomNavigationBar: const NavBar());
}
}
} | ||
|
||
class NavBarState extends State<NavBar> { | ||
int _index = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If your going with this implementation, I would actually recommend getting rid of the router and replacing it with a list or map of screen widgets. You'd essentially be replacing the router and making a single screen app with interchangeable screens. Since we are using a router there is some weirdness with the index.
|
||
switch (index) { | ||
case 0: | ||
Navigator.of(context).popUntil((route) => route.isFirst); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really a fan of routing like this, use pushReplacementNamed
and popAndPushNamed
when possible or replace the router as suggested above.
Navigator.of(context).popUntil((route) => route.isFirst); | ||
break; | ||
case 1: | ||
Navigator.pushNamed(context, '/logs'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use pushReplacementNamed
or popAndPushNamed
or replace the router as suggested above.
Navigator.pushNamed(context, '/logs'); | ||
break; | ||
case 2: | ||
Navigator.pushNamed(context, '/camera'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use pushReplacementNamed
or popAndPushNamed
or replace the router as suggested above.
Navigator.pushNamed(context, '/camera'); | ||
break; | ||
default: | ||
Navigator.pushNamed(context, '/sitl'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use pushReplacementNamed
or popAndPushNamed
or replace the router as suggested above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
With placeholders for camera, logs, and SITL pages.